package com.eling.elcms.travel.model;

import com.eling.elcms.basedoc.model.EnumSerializer;
import com.eling.elcms.core.dao.annotation.In;
import com.eling.elcms.core.dao.hibernate.search.EnumBridge;
import com.eling.elcms.core.model.BaseModel;
import com.eling.elcms.system.model.CommonUser;
import com.eling.elcms.travel.model.CheckInImplement.PaymentMethod;
import com.eling.elcms.travel.model.CheckInImplement.StatementStatus;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.hibernate.search.annotations.*;

import javax.persistence.*;
import java.util.Date;
import java.util.Set;

/**
 * 退房结算主表（入住登记状态为已登记时产生数据）
 * 
 * @author zhoulin
 *
 */
@Entity
@Indexed
@Table(name = "travel_checkoutdeal")
public class CheckOutDeal extends BaseModel {

	private static final long serialVersionUID = 2592102435557103184L;

	@Id
	@In
	@DocumentId
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long pkCheckOutDeal;

	/** 散客团预约 */
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkCheckInImplement")
	@IndexedEmbedded(depth = 1)
	private CheckInImplement checkInImplement;

	/** 结算日期 */
	@Column
	@Field
	private Date settlementDate;

	/** 经办人 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkUser")
	@IndexedEmbedded(depth = 1)
	private CommonUser operator;

	/** 结算方式 */
	@ElementCollection(fetch = FetchType.EAGER)
	@Enumerated(EnumType.STRING)
	@CollectionTable(name = "travel_nomem_paymentmethods", joinColumns = @JoinColumn(name = "pkNoMem"))
	@Column(name = "paymentMethods", nullable = false)
	private Set<PaymentMethod> paymentMethods;
	
	/** 已退押金*/
	@Column
	@Field
	private Double pledgeBack;

	/** 实收 */
	@Column
	@Field
	private Double money;

	/** 是否开票 */
	@Column
	@Field
	private Boolean billing;

	/** 开票日期 */
	@Column
	@Field
	private Date billingDate;

	/** 备注 */
	@Column
	@Field
	private String description;

	/** 结算状态 */
	@Enumerated(EnumType.STRING)
	@In
	@FieldBridge(impl = EnumBridge.class)
	private StatementStatus statementStatus;

	/** 状态 */
	@Enumerated(EnumType.STRING)
	@In
	@FieldBridge(impl = EnumBridge.class)
	private Status status;
	
	/** 是否销账*/
	@Column
	@Field
	private Boolean isSales;

	@Version
	private Integer version;

	@JsonSerialize(using = EnumSerializer.class)
	public enum Status {
		NoConfirm("待确认"), Confirm("已确认");
		private String display;

		Status(String display) {
			this.display = display;
		}

		public String getDisplay() {
			return display;
		}
	}

	public Long getPkCheckOutDeal() {
		return pkCheckOutDeal;
	}

	public void setPkCheckOutDeal(Long pkCheckOutDeal) {
		this.pkCheckOutDeal = pkCheckOutDeal;
	}

	public CheckInImplement getCheckInImplement() {
		return checkInImplement;
	}

	public void setCheckInImplement(CheckInImplement checkInImplement) {
		this.checkInImplement = checkInImplement;
	}

	public Date getSettlementDate() {
		return settlementDate;
	}

	public void setSettlementDate(Date settlementDate) {
		this.settlementDate = settlementDate;
	}

	public CommonUser getOperator() {
		return operator;
	}

	public void setOperator(CommonUser operator) {
		this.operator = operator;
	}

	public Set<PaymentMethod> getPaymentMethods() {
		return paymentMethods;
	}

	public void setPaymentMethods(Set<PaymentMethod> paymentMethods) {
		this.paymentMethods = paymentMethods;
	}

	public Double getMoney() {
		return money;
	}

	public void setMoney(Double money) {
		this.money = money;
	}

	public Boolean getBilling() {
		return billing;
	}

	public void setBilling(Boolean billing) {
		this.billing = billing;
	}

	public Date getBillingDate() {
		return billingDate;
	}

	public void setBillingDate(Date billingDate) {
		this.billingDate = billingDate;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public StatementStatus getStatementStatus() {
		return statementStatus;
	}

	public void setStatementStatus(StatementStatus statementStatus) {
		this.statementStatus = statementStatus;
	}

	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	public Double getPledgeBack() {
		return pledgeBack;
	}

	public void setPledgeBack(Double pledgeBack) {
		this.pledgeBack = pledgeBack;
	}

	public Boolean getIsSales() {
		return isSales;
	}

	public void setIsSales(Boolean isSales) {
		this.isSales = isSales;
	}
	
}
